package models;

import java.util.List;

import siena.Generator;
import siena.Id;
import siena.Index;
import siena.Model;
import siena.Query;

public class Activation extends Model
{
	@Id(Generator.AUTO_INCREMENT)
    public Long id;
	
	public String userID;
	
	public String UUID;
	
	public Activation(String userID, String uuid)
	{
		super();
		this.userID = userID;
		this.UUID = uuid;
	}
	
	static Query<Activation> all()
	{
        return Model.all(Activation.class);
    }
	
	public static Activation findById(String uuid) 
    {
        return all().filter("UUID", uuid).get();
    }
	
	 public static List<Activation> findByUser(User user) 
	 {
	        return all().filter("user", user).order("-created").fetch();
	 }
	
	public static void deletePendingActivations()
	{
		all().delete();
	}
}
